"""bitumen_backend URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from .views import (
    HealthCheckView, DashboardView, DashboardStatsView,
    ProfileView, ChangePasswordView
)

# 导入 drf-spectacular 提供的视图用于 Swagger 和 ReDoc
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView, SpectacularRedocView

health_check = HealthCheckView.as_view()
dashboard_view = DashboardView.as_view()
dashboard_stats_view = DashboardStatsView.as_view()
profile_view = ProfileView.as_view()
change_password_view = ChangePasswordView.as_view()

urlpatterns = [
    path('', dashboard_view, name='dashboard'),
    path('api/dashboard/stats/', dashboard_stats_view, name='dashboard_stats'),
    path('profile/', profile_view, name='profile'),
    path('api/profile/change-password/', change_password_view, name='change_password'),
    path('admin/', admin.site.urls),
    path('api/health/', health_check, name='health_check'),
    path('api/users/', include('user_app.urls')),
    path('api/auth/', include('auth_app.urls')),
    path('api/goods/', include('goods_app.urls')),
    path('api/vehicles/', include('vehicle_app.urls')),
    path('api/orders/', include('order_app.urls')),
    path('api/payments/', include('payment_app.urls')),
    path('api/notifications/', include('notification_app.urls')),
    path('api/tracking/', include('tracking_app.urls')),
    path('api/admin/review/', include('review_app.api_urls')),  # 添加审核管理API
    path('review/', include('review_app.urls')),  # 添加审核管理页面
    
    # API 文档路由
    path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
    path('swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
    path('redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)